import React, { useEffect,useState } from 'react'

export default function App() {
    let [person,setPerson] = useState([{
        id:'001',
        name:'小乔'
    },
    {
        id:'002',
        name:'大乔'
    },
    {
        id:'003',
        name:'小大乔'
    }
]);
useEffect(() => {
    console.log('person改变了');
},[person])
const addPerson= () =>{
    setPerson([...person,{id:Date.now(),name:'王昭君'}])
}
  return (
    <div>
        <button onClick = {addPerson}>添加数据</button>
        <ul>          
            {
               person.map(item =>{
                return <li key={item.id}>{item.name}</li>
               }) 
            }
        </ul>
    </div>
  )
}
